<!-- 设置 -->
<template>
    <view class="set-wrap">
        <!-- logo -->
        <view class="logo-box u-flex-col u-row-center u-col-center" >
            <image class="logo-img" style="width: 150rpx; height: 150rpx" :src=" data && data.avatar ? cdnurl(data.avatar) : cdnurl('/uploads/20210627/59472a1c9a94e533b04cad3df4d957b4.png') " mode="aspectFit"></image>
            <!-- <view class="app-name u-m-t-50">我的推荐人：{{ data && data.nickname ? data.nickname : '-' }}</view> -->
            <view class="app-name u-m-t-50" @click="copy(data.id)">推荐人ID：{{ data && data.id ? data.id : '-' }}  <text style="font-size: 24rpx;font-weight: 100;color: #ee0000;">点击复制</text></view>
            <view class="app-name u-m-t-50" @click="tel">联系电话：{{ data && data.mobile ? data.mobile : '-' }}</view>
			<view class="app-name u-m-t-50">微信同电话号</view>
        </view>
        <view class="daoshi">
			<view class="app-name u-m-t-50">我的导师：{{ data && data.daoshi && data.daoshi.nickname ? data.daoshi.nickname : '-' }}</view>
			<view class="app-name u-m-t-50" @click="copy(data.daoshi.id)">导师ID：{{ data && data.daoshi  && data.daoshi.id ? data.daoshi.id : '-' }}  <text style="font-size: 24rpx;font-weight: 100;color: #ee0000;">点击复制</text></view>
			<view class="app-name u-m-t-50" @click="phone">联系电话：{{ data && data.daoshi.mobile ? data.daoshi.mobile : '-' }}</view>
			<view class="app-name u-m-t-50">微信同电话号</view>
			
		</view>
    </view>
</template>

<script>
import { mapState, mapActions } from 'vuex';
import {BASE_URL} from "../../../env";
export default {
    components: {},
    data() {
        return {
            data: {}
        };
    },
    onLoad() {
        this.getInfo()
    },

    methods: {
        getInfo(){
            let _this = this
            this.$http('user.recommendInfo').then(res=>{
                _this.data = res.data
            })
        },

        cdnurl: function (url) {
            var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i");
            if (rule.test(url)) {
                return url
            }else{
                return BASE_URL+url
            }
        },
		
		tel(){
			if(this.data.mobile){
				uni.makePhoneCall({
					phoneNumber: this.data.mobile
				});
			}
		},
		
		phone(){
			if(this.data.daoshi && this.data.daoshi.mobile){
				uni.makePhoneCall({
					phoneNumber: this.data.daoshi.mobile
				});
			}
		},
		
		copy(data){
			uni.setClipboardData({
			    data: data,
			    success: function () {
			        uni.showToast({
			        	icon: 'none',
						title: "已复制到剪贴板"
			        })
			    }
			});
		}
    }
};
</script>

<style lang="scss">
page{ background: #fff;}
.set-box {
    background-color: #fff;
}



.daoshi {
    margin-top:40rpx;
    .app-name {
        font-size: 28rpx;
        color: #999;
		text-align:center;
    }
}

.logo-box {
    padding: 110rpx 0;
    .app-name {
        font-size: 32rpx;
        font-weight: 600;
        color: #333333;
    }
}
.copyright-box {
    .copyright-text {
        font-size: 22rpx;
        font-weight: 500;
        color: #c4c4c4;
    }
}
</style>
